﻿'********************************************************************************
'*
'*      メッキ着工/完了履歴　フォーム
'*      s122 电镀
'*      File Name : frmStartCompletePlateRSB.vb
'*      Title     : メッキ着工/完了履歴画面
'*      機能    　：メッキ着工/完了履歴
'*
'********************************************************************************
'----------------------------------<<修正履歴>>----------------------------------
'ﾊﾞｰｼﾞｮﾝ   日付       作業者        ｺﾒﾝﾄ
'--------- ---------- ------------ ----------------------------------------------
' V1.0.0   2017/02/16 T.Inose         新規作成
' V2.0.0   2017/06/23 T.Yutaro        蘇州対応
' V3.0.0   2017/12/19 T.Uchida        北京対応
' V4.0.0   2018/01/02 miao            北京対応
'********************************************************************************

Imports System.Text
Imports Newtonsoft.Json.Linq

Public Class frmStartCompletePlateRSB
    'ラックNoTag名
    Private Const RACK_NO_TAG As String = "COMP MS RACK NO"

    '前工程 ラックケースNo
    Dim rackCaseNo1 As String = String.Empty
    Dim rackCaseNo2 As String = String.Empty
    Dim objDBCondData As New clsDbCondData

    'ADD 苗 2018/1/11 
    '前工程廃棄フレーム枚数
    Private Const FRAME As String = "DISPOSAL FRAME NUM"
    'Dim strDISPOSAL_FRAME_NUM As String

    '>>2018/1/31 佐川 キャリア交換対応
    '実行モード
    '0:表示 1:着工 2:製造完成 3:計上完成
    Private execMode As String = VIEW
    '<<2018/1/31 佐川 キャリア交換対応

    'Add Miaojf 2019/11/22 Begin
    Overrides Sub selectTab()

        tabBase.SelectedIndex = 2

        Me.UpdateStyles()
    End Sub
    'Public Overrides Sub SetFocus()

    '    btnBarCode1.Enabled = True
    '    btnBarCode1.PerformClick()
    '    'txt0002.Enabled = True
    '    'txt0002.Focus()
    'End Sub
    'Add Miaojf 2019/11/22 END

    'タブコントロールの設定
    Public Overrides Sub SetTabControl()
        TabPageEqp.Enabled = False
    End Sub

    '照合結果設定
    Public Overrides Sub SetPassScore()
        PASS_SCORE = 2
        ReDim m_iScore(PASS_SCORE - 1)
        m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
    End Sub

    '照合結果クリア
    Public Overrides Sub InitualizeCollData()
        '>>2018/2/6 佐川 RSB確認結果一覧No32
        ' 前工程のラックNo2が空の項目はチェック済み(1)に設定する。
        If IsNothing(IcTag.container2) = False AndAlso IcTag.container2.Equals("") Then
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_CHECKED}
        Else
            m_iScore = {PASS_SCORE_WAIT_CHECK, PASS_SCORE_WAIT_CHECK}
        End If
        '<<2018/2/6 佐川 RSB確認結果一覧No32
        LotProcNonConformitymsg = False
    End Sub

    'イベント設定
    Public Overrides Sub SetHandler()
        ' 受入MSラックNo
        AddHandler txt0102.KeyPress, AddressOf txtRdyRackNo_KeyPress
        AddHandler txt0103.KeyPress, AddressOf txtRdyRackNo_KeyPress
        'AddHandler txt0103.LostFocus, AddressOf txtRdyRackNo_LostFocus
        AddHandler btnBarCode1.Click, AddressOf btnRackNoPlate_Click

        ' 完了MSラックNo
        AddHandler txt0202.KeyPress, AddressOf txtPreRackNo_KeyPress
        AddHandler txt0203.KeyPress, AddressOf txtPreRackNo_KeyPress
        AddHandler btnBarCode2.Click, AddressOf btnRackNoPlate_Click

        ' >> 20180710 佐川 ラックNo途入力改善
        AddHandler txt0102.Click, AddressOf rackInputFocus
        AddHandler lbl0102.Click, AddressOf rackInputFocus
        AddHandler txt0103.Click, AddressOf rackInputFocus
        AddHandler lbl0103.Click, AddressOf rackInputFocus
        AddHandler lbl0202.Click, AddressOf afterRackInputFocus
        AddHandler txt0202.Click, AddressOf afterRackInputFocus
        AddHandler lbl0203.Click, AddressOf afterRackInputFocus
        AddHandler txt0203.Click, AddressOf afterRackInputFocus
        ' << 20180710 佐川 ラックNo途入力改善
    End Sub
    Private Sub rackNoMD_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) _
        Handles txt0102.PreviewKeyDown, txt0103.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtRdyRackNo_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub
    'Lot Noでデータベースからデータを取得する
    Public Overrides Sub GetDataByIcTag()

        '初期化
        InputDataClear()

        'ICタグのデータで画面を設定する
        SetFromTag()
        If m_MoveInCheck = False Then Exit Sub
        '工程明細テーブル取得
        setDetailData()

        '前工程情報取得、設定
        '>>2018/1/31 佐川 キャリア交換対応
        rackCaseNo1 = IcTag.container1
        rackCaseNo2 = IcTag.container2
        '<<2018/1/31 佐川 キャリア交換対応
        For Each drPreDetail In dtPreDetailData.Rows
            '>>2018/1/31 佐川 キャリア交換対応
            'If drPreDetail("MNF_CND_TAG").Equals(RACK_NO_TAG) AndAlso drPreDetail("SEQ") = 1 Then
            '    '前工程 ラックケースNo1
            '    rackCaseNo1 = drPreDetail("ACTUAL_MODEL")
            'End If
            'If drPreDetail("MNF_CND_TAG").Equals(RACK_NO_TAG) AndAlso drPreDetail("SEQ") = 2 Then
            '    '前工程 ラックケースNo2
            '    rackCaseNo2 = drPreDetail("ACTUAL_MODEL")
            'End If
            '<<2018/1/31 佐川 キャリア交換対応
            'ADD 苗 2018/1/11 BEGIN
            'If drPreDetail("MNF_CND_TAG").Equals(FRAME) Then
            '    '前工程 廃棄フレーム数
            '    strDISPOSAL_FRAME_NUM = drPreDetail("ACTUAL_MODEL")
            'End If
            'ADD 苗 2018/1/11 END
        Next

        '工程明細テーブル取得
        setDetailData()

        For Each dr In dtDetailData.Rows
            If DBNullTOblank(dr("MNF_CND_TAG")).Equals(lbl0100.Tag) AndAlso DBNullTOblank(dr("SEQ")) = 1 Then 'UPD MIAO 2018/10/25
                'ラックNo.1
                txt0102.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/10/25
                txt0102.BackColor = ENTERED_INIT_COLOR
                lbl0102.BackColor = ENTERED_INIT_COLOR
            End If
            If DBNullTOblank(dr("MNF_CND_TAG")).Equals(lbl0100.Tag) AndAlso DBNullTOblank(dr("SEQ")) = 2 Then 'UPD MIAO 2018/10/25
                'ラックNo.2
                txt0103.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/10/25
                txt0103.BackColor = ENTERED_INIT_COLOR
                lbl0103.BackColor = ENTERED_INIT_COLOR
            End If
            If DBNullTOblank(dr("MNF_CND_TAG")).Equals(lbl0200.Tag) AndAlso DBNullTOblank(dr("SEQ")) = 1 Then 'UPD MIAO 2018/10/25
                'ラックNo.1
                txt0202.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/10/25
                txt0202.BackColor = ENTERED_INIT_COLOR
                lbl0202.BackColor = ENTERED_INIT_COLOR
            End If
            If DBNullTOblank(dr("MNF_CND_TAG")).Equals(lbl0200.Tag) AndAlso DBNullTOblank(dr("SEQ")) = 2 Then 'UPD MIAO 2018/10/25
                'ラックNo.2
                txt0203.Text = DBNullTOblank(dr("ACTUAL_MODEL")) 'UPD MIAO 2018/10/25
                txt0203.BackColor = ENTERED_INIT_COLOR
                lbl0203.BackColor = ENTERED_INIT_COLOR
            End If
            'ADD 苗 2018/1/11 BEGIN
            'If dr("MNF_CND_TAG").Equals(FRAME) Then
            '    '前工程 廃棄フレーム数
            '    strDISPOSAL_FRAME_NUM = dr("ACTUAL_MODEL")
            'End If
            'ADD 苗 2018/1/11 END

        Next

        '工程ヘッダーテーブル取得
        getHeadData()

        'ヘッダーの設定
        With m_dtMat
            If .Rows.Count > 0 Then
                '着完日時
                DisplayDate()
            Else
                If m_dtMat.Columns.Count > 0 Then
                    .Rows.Add()
                Else
                    .Columns.Add("BEGIN_TIME")
                    .Rows.Add()
                End If
            End If
        End With

        If m_fColl AndAlso txtOptNoStt.TextLength > 0 Then
            If m_ProcessStatus = ProcessStatus.TagSet Then
                m_ProcessStatus = ProcessStatus.Preprocess
                OnProcessStatusChanged(Me)
            End If
        End If
    End Sub

    '初期化、背景色の設定
    Public Sub InputDataClear()

        '>>2018/1/30 佐川 キャリア交換対応
        execMode = VIEW
        '<<2018/1/30 佐川 キャリア交換対応

        'ラックNo（着工前）
        txt0102.Text = String.Empty
        txt0103.Text = String.Empty
        txt0102.BackColor = BARCODE_INIT_COLOR
        lbl0102.BackColor = BARCODE_INIT_COLOR
        txt0103.BackColor = BARCODE_INIT_COLOR
        lbl0103.BackColor = BARCODE_INIT_COLOR
        btnBarCode1.Enabled = True

        'ラックNo（着工後）
        txt0202.Text = String.Empty
        txt0203.Text = String.Empty
        txt0202.BackColor = BARCODE_INIT_COLOR
        lbl0202.BackColor = BARCODE_INIT_COLOR
        txt0203.BackColor = BARCODE_INIT_COLOR
        lbl0203.BackColor = BARCODE_INIT_COLOR
        btnBarCode2.Enabled = False

        '開始作業者No
        txtOptNoStt.Text = String.Empty
        '終了作業者No
        txtOptNoEnd.Text = String.Empty

    End Sub

    '画面データ保存（着工時）
    Public Overrides Function SaveEquipMat(ByRef szBeginTime As DateTime) As Boolean

        '>>2018/1/31 佐川 キャリア交換対応
        execMode = BEGIN
        '<<2018/1/31 佐川 キャリア交換対応

        dtDBUpd.Clear()
        If saveDetail(BEGIN) < 0 Then
            Return False
        Else
            Return True
        End If
    End Function

    '画面データ保存（製造完成）
    Public Overrides Function SaveCompleteInfo(Optional ByVal status As ProcessStatus = ProcessStatus.ManufComplete) As Integer

        '>>2018/1/31 佐川 キャリア交換対応
        execMode = COMPLETE
        '<<2018/1/31 佐川 キャリア交換対応

        dtDBUpd.Clear()
        Return saveDetail(COMPLETE)
    End Function

    '画面データ保存（計上完成）
    Public Overrides Function SaveTotalInfo() As Integer

        '>>2018/1/31 佐川 キャリア交換対応
        execMode = TOTAL
        '<<2018/1/30 佐川 キャリア交換対応

        dtDBUpd.Clear()
        Return saveDetail(TOTAL)
    End Function

    '工程明細テーブル更新処理
    Private Function saveDetail(ByVal type As String) As Integer
        Dim rowsCnt As Integer = dtDBUpd.Rows.Count
        Dim addIndex As Integer = 0


        ' (着工前)
        ' ラックNo1
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0100.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 1
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0102.Text
        addIndex += 1

        ' ラックNo2
        dtDBUpd.Rows.Add()
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0100.Tag
        dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
        dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 2
        dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0103.Text
        addIndex += 1

        If type <> BEGIN Then
            ' (着工後)
            ' ラックNo1
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 1
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0202.Text
            addIndex += 1

            ' ラックNo2
            dtDBUpd.Rows.Add()
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = lbl0200.Tag
            dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 2
            dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = txt0203.Text
            addIndex += 1


            ''ADD 苗 2018/1/11 BEGIN
            '' 廃棄フレーム数
            'dtDBUpd.Rows.Add()
            'dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG") = FRAME
            'dtDBUpd.Rows(rowsCnt + addIndex)("MNF_CND_TAG_FLG") = 0
            'dtDBUpd.Rows(rowsCnt + addIndex)("SEQ") = 1
            'dtDBUpd.Rows(rowsCnt + addIndex)("ACTUAL_MODEL") = strDISPOSAL_FRAME_NUM
            'addIndex += 1
            ''ADD 苗 2018/1/11 END
        End If
        'DEL 2018/1/3 苗修正　BEGIN　
        'Return m_cEquipMat.SaveDetail(lotNo, lblProcessCD.Tag, type,
        '                          m_szTable, dtDBUpd, m_dtHeader,
        '                          m_cIdohyo.EquipInfo.szEquipNo, serverTime)
        'DEL 2018/1/3 苗修正　END　
        Return m_cEquipMat.SaveDetail(lotNo, lblProcessCD.Text, type,
                                  m_szTable, dtDBUpd, m_dtHeader,
                                  m_cIdohyo.EquipInfo.szEquipNo, serverTime)
    End Function

    '計上完成時チェック処理
    Public Overrides Function EndCheck() As Boolean
        Dim checkFlg As Boolean = True

        '完了MSラックNo1の空白チェック
        checkFlg = checkBlank(txt0202.Text, lbl0200.Text)
        If Not checkFlg Then
            checkColor(txt0202, checkFlg, lbl0202.Name)
            Return checkFlg
        End If

        '完了MSラックNo1,2の重複チェック
        If txt0202.Text.Equals(txt0203.Text) Then
            checkFlg = False
            setCheckInfo(getMsgStr("MSG00064", lbl0200.Text))
            checkColor(txt0202, checkFlg, lbl0202.Name)
            Return checkFlg
        End If

        '着工時のMSラックNoとの同一チェック
        '完了MSラックNo1
        If Not (txt0202.Text.Equals(txt0102.Text) Or txt0202.Text.Equals(txt0103.Text)) Then
            checkFlg = False
            setCheckInfo(getMsgStr("MSG00089", lbl0200.Text & "No1"))
            checkColor(txt0202, checkFlg, lbl0202.Name)
            Return checkFlg
        End If
        '完了MSラックNo2
        If Not (txt0203.Text.Equals(txt0102.Text) Or txt0203.Text.Equals(txt0103.Text)) Then
            checkFlg = False
            setCheckInfo(getMsgStr("MSG00089", lbl0200.Text & "No2"))
            checkColor(txt0203, checkFlg, lbl0203.Name)
            Return checkFlg
        End If

        Return checkFlg
    End Function

    '画面項目の表示切替
    Public Overrides Sub ConfScreenItem()
        If txtLotNo.TextLength > 0 Then
            If IcTag.Status = TagProcessStatus.Ready Then
                '着工待ち
                btnBarCode1.Enabled = True
                btnBarCode2.Enabled = False
                '受入MSラックNo
                txt0102.BackColor = BARCODE_INIT_COLOR
                lbl0102.BackColor = BARCODE_INIT_COLOR
                txt0103.BackColor = BARCODE_INIT_COLOR
                lbl0103.BackColor = BARCODE_INIT_COLOR
                '完了MSラックNo
                txt0202.BackColor = NORMAL_INIT_COLOR
                lbl0202.BackColor = NORMAL_INIT_COLOR
                txt0203.BackColor = NORMAL_INIT_COLOR
                lbl0203.BackColor = NORMAL_INIT_COLOR
            Else
                '着工中
                'btnBarCode1.Enabled = False
                btnBarCode2.Enabled = True
                '受入MSラックNo
                txt0102.BackColor = NORMAL_INIT_COLOR
                lbl0102.BackColor = NORMAL_INIT_COLOR
                txt0103.BackColor = NORMAL_INIT_COLOR
                lbl0103.BackColor = NORMAL_INIT_COLOR
                '完了MSラックNo
                txt0202.BackColor = BARCODE_INIT_COLOR
                lbl0202.BackColor = BARCODE_INIT_COLOR
                txt0203.BackColor = BARCODE_INIT_COLOR
                lbl0203.BackColor = BARCODE_INIT_COLOR
            End If
        End If
    End Sub
    'DEL Miao 2019/11/24 Begin
    'b-siteに計上せずに着完
    Public Overrides Sub WorkStart()
        Try
            'PQC CHECK
            If chkMatChanged() Then
                PutLog(Me.ToString, "PQC", "PLT WorkStart PQC CHECK.") '2020/8/8 ver.57
                chkPQC()
            End If
        Catch ex As Exception
            setCheckInfo("PQC接口连接失败。")
        End Try
        If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then
            If chkPlateSYS() Then
                outHeader = New InSiteWebService.OutHeader
                outHeader.Status = STS_SUCCESS
                MyBase.JiSuccess()
            End If
        Else
            MyBase.JiSuccess()
        End If
    End Sub
    ' 着工をスキップする場合、画面側コードでTrueを返す
    Overrides Function IsJiSkiped() As Boolean
        Return True
    End Function
    'DEL Miao 2019/11/24 End
    ' 着工前ラックNo用KeyPress
    Protected Sub txtRdyRackNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox)
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
            Dim lblMsg As Label = txtData.Parent.Controls.Find("lbl0100", False)(0)
            If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then

                'Add 苗 2019/11/24 Begin
                Dim tmpLotNo As String
                tmpLotNo = getLotNoByRack(txtData.Text)
                If txtLotNo.Text = "" Or (tmpLotNo <> "" And txtLotNo.Text <> tmpLotNo) Then
                    txtLotNo.Text = tmpLotNo
                    If txtLotNo.Text.Trim() <> "" Then
                        txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                        'If AutoManualMode = 0 Then
                        setBeforeRackNo()
                        'End If
                        'm_iScore = {PASS_SCORE_CHECKED, PASS_SCORE_CHECKED}
                        'Exit Sub
                    End If
                End If
                'Add 苗 2019/11/24 End

            End If
            ' 空白チェック
            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) Then
                ' LostFocusがラックNo1の場合，空白チェックを行う
                If String.IsNullOrEmpty(txtData.Text) Then
                    setCheckInfo(getMsgStr("MSG00020", lblMsg.Text))
                    checkColor(sender, False, lblSys.Name)
                    'txtData.Enabled = False '2018/2/22 佐川 ラックNo入力動作を統一
                    m_iScore(0) = PASS_SCORE_WAIT_CHECK
                    Exit Sub
                End If
                '>>20180313 大賀 搬送容器桁数チェックを共通化
                If Not txtData.Text.Equals("") Then
                    ' ラックNoの桁数チェック
                    If Not isCheckCaseLength(txtData, MS_RACK_CASE_NO_LENGTH, lblSys) Then
                        m_iScore(0) = PASS_SCORE_WAIT_CHECK
                        Exit Sub
                    End If
                End If
                '<<20180313 大賀 搬送容器桁数チェックを共通化
            Else
                '>>20180313 大賀 搬送容器桁数チェックを共通化
                If Not txtData.Text.Equals("") Then
                    ' ラックNoの桁数チェック
                    If Not isCheckCaseLength(txtData, MS_RACK_CASE_NO_LENGTH, lblSys) Then
                        m_iScore(1) = PASS_SCORE_WAIT_CHECK
                        Exit Sub
                    End If
                End If
                '<<20180313 大賀 搬送容器桁数チェックを共通化
                ' ラック１、２の重複チェック
                If txt0102.Text = txtData.Text Then
                    ' １、２が重複
                    setCheckInfo(getMsgStr("MSG00064", lblMsg.Text))
                    checkColor(sender, False, lblSys.Name)
                    '>> 2018/2/22 佐川 ラックNo入力動作を統一
                    'txtData.Enabled = False
                    txtData.SelectAll()
                    '<< 2018/2/22 佐川 ラックNo入力動作を統一
                    m_iScore(1) = PASS_SCORE_WAIT_CHECK
                    Exit Sub
                End If
            End If


            ' 前工程とのチェック
            If Not (txtData.Text.Equals(rackCaseNo1) Or txtData.Text.Equals(rackCaseNo2)) Then
                ' 一致していない
                setCheckInfo(getMsgStr("MSG00052", lblMsg.Text))
                checkColor(sender, False, lblSys.Name)
                '>> 2018/2/22 佐川 ラックNo入力動作を統一
                txtData.SelectAll()
                'txt0102.Enabled = False
                'txt0103.Enabled = False
                m_iScore(CInt(txtData.Name.ToString.Substring(6, 1)) - 2) = PASS_SCORE_WAIT_CHECK
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
                Exit Sub
            End If

            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) Then
                m_iScore(0) = PASS_SCORE_CHECKED
            Else
                m_iScore(1) = PASS_SCORE_CHECKED
            End If

            '>>2018/2/6 佐川 RSB確認結果一覧No32
            txtData.BackColor = ENTERED_INIT_COLOR
            lblSys.BackColor = ENTERED_INIT_COLOR
            txtData.Enabled = False
            If AutoManualMode = 0 And AUTO_MANUAL_BTN = TYPE_AUTO Then
                If Command_LD_Received = False Then Exit Sub
            End If


            CheckCollScore()

            'No1の時かつ、着工前の場合にフォーカス移動を行う
            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) And IcTag.Status = TagProcessStatus.Ready Then

                Dim tag As Integer = txtData.Name.ToString.Substring(3, 4)
                Dim nextLbl As Label = txtData.Parent.Controls.Find(String.Format("lbl{0:0000}", tag + 1), False)(0)
                Dim nextTxtData As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0:0000}", tag + 1), False)(0)

                nextTxtData.Enabled = True
                nextTxtData.Focus()
                nextTxtData.SelectAll()
                nextTxtData.BackColor = Color.Cyan
                nextLbl.BackColor = Color.Cyan
            End If
            '<<2018/2/6 佐川 RSB確認結果一覧No32
        End If
    End Sub

    ' 着工後ラックNo用KeyPress
    Protected Sub txtPreRackNo_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)

        '頭に付いている'%'を消す
        Static Dim fIsPercentInput As Boolean = False
        If e.KeyChar = CChar("%") OrElse e.KeyChar = CChar("％") Then
            fIsPercentInput = True
            e.Handled = True
            Exit Sub
        End If
        If fIsPercentInput Then
            fIsPercentInput = False
            e.Handled = True
            Exit Sub
        End If

        If e.KeyChar = vbCr Then
            Dim txtData As TextBox = CType(sender, TextBox)
            txtData.Text = txtData.Text.ToUpper 'Add 苗 2018/4/10
            Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
            Dim lblMsg As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}00", txtData.Tag.ToString), False)(0)

            ' 空白チェック
            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) Then
                ' LostFocusがラックNo1の場合，空白チェックを行う
                If String.IsNullOrEmpty(txtData.Text) Then
                    setCheckInfo(getMsgStr("MSG00020", lblMsg.Text))
                    checkColor(sender, False, lblSys.Name)
                    'txtData.Enabled = False '2018/2/22 佐川 ラックNo入力動作を統一
                    Exit Sub
                End If
            Else
                ' ラック１、２の重複チェック
                If txt0202.Text = txtData.Text Then
                    ' １、２が重複
                    setCheckInfo(getMsgStr("MSG00064", lblMsg.Text))
                    checkColor(sender, False, lblSys.Name)
                    '>> 2018/2/22 佐川 ラックNo入力動作を統一
                    txtData.SelectAll()
                    'txtData.Enabled = False
                    '<< 2018/2/22 佐川 ラックNo入力動作を統一
                    Exit Sub
                End If
            End If
            '>>20180313 大賀 搬送容器桁数チェックを共通化
            If Not txtData.Text.Equals("") Then
                ' ラックNoの桁数チェック
                If Not isCheckCaseLength(txtData, MS_RACK_CASE_NO_LENGTH, lblSys) Then
                    Exit Sub
                End If
            End If
            '<<20180313 大賀 搬送容器桁数チェックを共通化

            ' 前工程とのチェック
            If Not (txtData.Text.Equals(rackCaseNo1) Or txtData.Text.Equals(rackCaseNo2)) Then
                ' 一致していない
                setCheckInfo(getMsgStr("MSG00089", lblMsg.Text))
                checkColor(sender, False, lblSys.Name)
                '>> 2018/2/22 佐川 ラックNo入力動作を統一
                txtData.SelectAll()
                'txtData.Enabled = False
                '<< 2018/2/22 佐川 ラックNo入力動作を統一
                Exit Sub
            End If

            ' フォーカス移動 No1の時だけ
            If txtData.Name = String.Format("txt{0}02", txtData.Tag.ToString) Then
                Dim tag As Integer = txtData.Name.ToString.Substring(3, 4)
                Dim nextLbl As Label = txtData.Parent.Controls.Find(String.Format("lbl{0:0000}", tag + 1), False)(0)
                Dim nextTxtData As TextBox = txtData.Parent.Controls.Find(String.Format("txt{0:0000}", tag + 1), False)(0)

                nextTxtData.Enabled = True
                nextTxtData.Focus()
                nextTxtData.SelectAll()
                nextTxtData.BackColor = Color.Cyan
                nextLbl.BackColor = Color.Cyan
            End If
            txtData.BackColor = ENTERED_INIT_COLOR
            lblSys.BackColor = ENTERED_INIT_COLOR
            txtData.Enabled = False
        End If
    End Sub

    ' ラックNoメッキ用バーコードクリック
    Protected Sub btnRackNoPlate_Click(sender As Object, e As EventArgs)
        Dim btn As Button = CType(sender, Button)

        ' 画面の初期化
        For i = 2 To 3 ' ラックNoの入力は02～03。
            Dim textData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}{1:00}", btn.Tag.ToString, i), False)(0)
            Dim labelData As Label = textData.Parent.Controls.Find(String.Format("lbl{0}{1:00}", textData.Tag.ToString, i), False)(0)
            textData.Text = String.Empty
            textData.Enabled = False '2018/2/22 佐川 ラックNo入力動作を統一
            textData.BackColor = BARCODE_INIT_COLOR
            labelData.BackColor = BARCODE_INIT_COLOR
        Next

        ' 入力フォーカスの設定
        Dim txtData As TextBox = btn.Parent.Controls.Find(String.Format("txt{0}02", btn.Tag.ToString), False)(0)
        Dim lblData As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}02", txtData.Tag.ToString), False)(0)
        txtData.Enabled = True
        txtData.Focus()
        txtData.SelectAll()
        txtData.BackColor = Color.Cyan
        lblData.BackColor = Color.Cyan

        '受入MSラックNoのバーコードボタン押下時は入力チェックスコアを初期化する
        If btn.Tag = "01" Then
            '>>2018/2/6 佐川 RSB確認結果一覧No32
            InitualizeCollData()
            '<<2018/2/6 佐川 RSB確認結果一覧No32
        End If
    End Sub

    ' 着工前ラックNo用LostFocus
    Protected Sub txtRdyRackNo_LostFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        Dim txtData As TextBox = CType(sender, TextBox)
        Dim lblSys As Label = txtData.Parent.Controls.Find(String.Format("lbl{0}", txtData.Name.ToString.Substring(3, 4)), False)(0)
        Dim lblMsg As Label = txtData.Parent.Controls.Find("lbl0100", False)(0)

        ' ラック１、２の重複チェック
        If txt0102.Text = txtData.Text Then
            ' １、２が重複
            setCheckInfo(getMsgStr("MSG00064", lblMsg.Text))
            checkColor(sender, False, lblSys.Name)
            txtData.Enabled = False
            m_iScore(1) = PASS_SCORE_WAIT_CHECK
            Exit Sub
        End If

        ' 前工程とのチェック
        If Not (txtData.Text.Equals(rackCaseNo1) Or txtData.Text.Equals(rackCaseNo2)) Then
            ' 一致していない
            setCheckInfo(getMsgStr("MSG00052", lblMsg.Text))
            checkColor(sender, False, lblSys.Name)
            txtData.Enabled = False
            m_iScore(0) = PASS_SCORE_WAIT_CHECK
            Exit Sub
        End If
        m_iScore(1) = PASS_SCORE_CHECKED
        CheckCollScore()

    End Sub
    Overrides Sub setInitializForm_FLG()
        initializForm_FLG = True
    End Sub

    '計上完成正常時の画面初期化
    Protected Overrides Sub initializForm()
        MyBase.initializForm()
        InputDataClear()
        MyBase.frmStartCompleteBase_Load(New Object, New EventArgs)

    End Sub

    '受入MSラックNoタブキー対応
    Private Sub rdyRackNo_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txt0102.PreviewKeyDown, txt0103.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtRdyRackNo_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '完了MSラックNoタブキー対応
    Private Sub preRackNo_PreviewKeyDown(ByVal sender As Object, ByVal e As PreviewKeyDownEventArgs) Handles txt0202.PreviewKeyDown, txt0203.PreviewKeyDown
        'タブキーが押下された場合は、改行コードと見なし処理を行う
        If e.KeyCode = Keys.Tab Then
            e.IsInputKey = True
            txtPreRackNo_KeyPress(sender, New KeyPressEventArgs(vbCr))
        End If
    End Sub

    '>>2018/1/31 佐川 キャリア交換対応
    'IcTag保存内容設定
    Protected Overrides Sub icTagDataSet()
        '製造完成、計上完成時は画面入力値の値を設定する。
        If execMode.Equals(COMPLETE) Or execMode.Equals(TOTAL) Then
            IcTag.container1 = txt0202.Text
            IcTag.container2 = txt0203.Text
            IcTag.container3 = String.Empty
            IcTag.container4 = String.Empty
            IcTag.container5 = String.Empty
            '>>2018/2/13 大賀 サンプル数量対応
            IcTag.plateEquipNo = g_EQUIP_NO
            '>>2018/2/13 大賀 サンプル数量対応
        Else
            '初期値をそのまま保存するため、変更しない。
        End If
    End Sub
    '<<2018/1/31 佐川 キャリア交換対応

    ' >> 20180307 大賀 作業者入力確定時に次の入力にフォーカスを移動する
    ''' <summary>
    ''' 作業者入力後のフォーカスを各画面で設定する
    ''' 各画面でオーバーライドされない場合はTabIndex順に移動する
    ''' </summary>
    ''' <param name="inputType">作業者入力タイプ</param>
    ''' <param name="nowControl">対象コントロール</param>
    Protected Overrides Sub setNextFocus(ByVal inputType As OPERATER_INPUT_TYPE, ByVal nowControl As Control)
        If m_ProcessStatus <> ProcessStatus.Ready Then  ' ロット未入力の場合は処理しない
            If IcTag.Status = TagProcessStatus.Ready Then   ' 未着工
                If inputType = OPERATER_INPUT_TYPE.START_OPE Then
                    tabBase.SelectedTab = TabPageSp ' タブの移動
                    If String.IsNullOrEmpty(txt0102.Text) Then  ' 未入力の場合に入力可能にする
                        btnBarCode1.PerformClick()  ' バーコード入力ボタンを押す
                        Exit Sub
                    End If
                End If
            ElseIf IcTag.Status = TagProcessStatus.Processing Then  ' 着工中
                If inputType = OPERATER_INPUT_TYPE.END_OPE Then
                    tabBase.SelectedTab = TabPageSp ' タブの移動
                    If String.IsNullOrEmpty(txt0202.Text) Then  ' 未入力の場合に入力可能にする
                        btnBarCode2.PerformClick()  ' バーコード入力ボタンを押す
                        Exit Sub
                    End If
                End If
            ElseIf IcTag.Status = TagProcessStatus.ManufComplete Then ' 製造完成

            End If
        End If
        ' 各画面個別のフォーカスに移動しない場合は次のTabIndexに移動
        SelectNextControl(nowControl, True, True, True, True)
    End Sub
    ' << 20180307 大賀 作業者入力確定時に次の入力にフォーカスを移動する

    ' >> 20180308 大賀 着工キャンセル時にbSite連携を行わない
    ' <summary>
    ' Baseのロットキャンセルボタンをオーバーライドし、bSiteへの送信をスキップする
    ' </summary>
    'Protected Overrides Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs)
    '    If MsgBox(getMsgStr("MSG10021"), MsgBoxStyle.YesNo) = MsgBoxResult.No Then
    '        Exit Sub
    '    End If
    '    serverTime = m_cData.GetServerTime  ' bSite通信がないためDBサーバー時刻で更新
    '    MyBase.JcSuccess()
    '    MyBase.initializForm()
    '    InputDataClear()
    'End Sub
    ' << 20180308 大賀 着工キャンセル時にbSite連携を行わない

    ' >> 20180710 佐川 ラックNo途入力改善
    Public Overrides Sub rackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        '未着工のみ選択可能にする
        If IcTag.Status = TagProcessStatus.Ready Then
            MyBase.rackInputFocus(sender, e)
        End If
    End Sub

    Public Sub afterRackInputFocus(ByVal sender As Object, ByVal e As System.EventArgs)
        '着工中のみ選択可能にする
        If IcTag.Status = TagProcessStatus.Processing Then
            MyBase.rackInputFocus(sender, e)
        End If
    End Sub
    ' << 20180710 佐川 ラックNo途入力改善

    '--自動着完工用実装分--BEGIN　2019/11/29
    Protected Overrides Sub setBeforeRackNo(Optional inputRackNo As String = "")
        If IsNothing(IcTag.szLotNo) = False Then
            If IcTag.container1 <> "" Then
                txt0102.Text = IcTag.container1
            End If
            If IcTag.container2 <> "" Then
                txt0103.Text = IcTag.container2
            End If
            m_iScore(CInt(txt0103.Tag) - 1) = PASS_SCORE_CHECKED
        End If
    End Sub

    Protected Overrides Function setAfterRackNo(receiveData As receiveCommandData) As Boolean
        If receiveData.UrackNoList.Count = 0 Then
            Return False
        End If
        '完工MS料盒设置
        If IsNothing(receiveData.UrackNoList(0)) = False Then
            txt0202.Text = receiveData.UrackNoList(0)
        End If
        If IsNothing(receiveData.UrackNoList(1)) = False Then
            txt0203.Text = receiveData.UrackNoList(1)
        End If
        Return True
    End Function
    ''' <summary>
    ''' 设置画面控件是否可用
    ''' </summary>
    ''' <param name="mode">True:自动状态，False：手动状态</param>
    Protected Overrides Sub setAutoScreen(mode As Boolean)

        Dim setColor As Color = NORMAL_INIT_COLOR
        Dim setEnabled As Boolean = Not (mode)

        '完工后，是否清空画面，清空后ictag也被清空（手动时为true,自动时为false)
        initializForm_FLG = setEnabled

        If mode = True Then
            setColor = NORMAL_INIT_COLOR
        Else
            setColor = BUTTON_INIT_COLOR
        End If
        txt0102.Enabled = setEnabled
        txt0103.Enabled = setEnabled
        txt0202.Enabled = setEnabled
        txt0203.Enabled = setEnabled

        lbl0102.BackColor = setColor
        txt0102.BackColor = setColor

        lbl0103.BackColor = setColor
        txt0103.BackColor = setColor

        lbl0202.BackColor = setColor
        txt0202.BackColor = setColor

        lbl0203.BackColor = setColor
        txt0203.BackColor = setColor

    End Sub

    '--自動着完工用実装分--END　2019/11/29
    Public Function chkPlateSYS() As Boolean

        Dim rtn As Boolean = False

        Dim PlateSYS As New ServiceReferenceEdms.EdmsWebIFServiceClient
        Dim PrevLot As String

        Dim tokenReq As New ServiceReferenceEdms.GetTokenRequest
        Dim tokenRes As New ServiceReferenceEdms.GetTokenResponse
        tokenReq.User = "edsf"
        tokenReq.Password = "edsf"

        Dim sfTransReq As New ServiceReferenceEdms.SfTransRequest
        Dim sfTransRes As New ServiceReferenceEdms.SfTransResponse
        Try

            tokenRes = PlateSYS.ServiceReferenceEdms_EdmsWebIFService_GetToken(tokenReq)

            Dim dvRESIN As DataRow()
            Dim dvFrameKatamei As DataRow()
            Dim strResin As String = ""
            Dim strFrameKatamei As String = ""

            setJyokenALLData(txtLotNo.Text)

            dvRESIN = dtJyokenData.Select("KOMOKUNAME='RESIN'")
            dvFrameKatamei = dtJyokenData.Select("KOMOKUNAME='FRAME SUBSTRATE NAME'")
            If dvRESIN.Length <> 0 AndAlso IsDBNull(dvRESIN(0)("KOMOKUDATA")) = False Then
                strResin = dvRESIN(0)("KOMOKUDATA")
            End If
            If dvFrameKatamei.Length <> 0 AndAlso IsDBNull(dvFrameKatamei(0)("KOMOKUDATA")) = False Then
                strFrameKatamei = dvFrameKatamei(0)("KOMOKUDATA")
            End If
            If strResin = "" OrElse strFrameKatamei = "" Then
                PrevLot = getPrevLot(txtLotNo.Text)
                If PrevLot <> "" Then
                    setJyokenALLData(PrevLot)
                    dvRESIN = dtJyokenData.Select("KOMOKUNAME='RESIN'")
                    dvFrameKatamei = dtJyokenData.Select("KOMOKUNAME='FRAME SUBSTRATE NAME'")
                End If
            End If

            If dvRESIN.Length <> 0 AndAlso IsDBNull(dvRESIN(0)("KOMOKUDATA")) = False Then
                strResin = dvRESIN(0)("KOMOKUDATA")
            End If
            If dvFrameKatamei.Length <> 0 AndAlso IsDBNull(dvFrameKatamei(0)("KOMOKUDATA")) = False Then
                strFrameKatamei = dvFrameKatamei(0)("KOMOKUDATA")
            End If

            sfTransReq.User = tokenReq.User
            sfTransReq.Token = tokenRes.GetTokenReturn
            sfTransReq.Parameter = "{" & Chr(34) & "KeyNo" & Chr(34) & ":" & Chr(34) & txtLotNo.Text & Chr(34) & ","
            sfTransReq.Parameter &= Chr(34) & "Katamei" & Chr(34) & ":" & Chr(34) & lblkindNm.Text & Chr(34) & ","
            sfTransReq.Parameter &= Chr(34) & "FrameKatamei" & Chr(34) & ":" & Chr(34) & strFrameKatamei & Chr(34) & ","
            'sfTransReq.Parameter &= Chr(34) & "FlowChartKatamei" & Chr(34) & ":" & Chr(34) & "FC-A112-D6-AAAE" & Chr(34) & ","
            sfTransReq.Parameter &= Chr(34) & "Tnyusu" & Chr(34) & ":" & IcTag.iFrame & ","
            sfTransReq.Parameter &= Chr(34) & "FeedBoxNum" & Chr(34) & ":1,"
            sfTransReq.Parameter &= Chr(34) & "Resin" & Chr(34) & ":" & Chr(34) & strResin & Chr(34) & ","
            sfTransReq.Parameter &= Chr(34) & "EquipNo" & Chr(34) & ":" & Chr(34) & lblEquipID.Text & Chr(34) & ","
            sfTransReq.Parameter &= Chr(34) & "Rackid" & Chr(34) & ":" & Chr(34) & txt0102.Text & Chr(34) & ","
            sfTransReq.Parameter &= Chr(34) & "EmployeeNum" & Chr(34) & ":" & Chr(34) & txtOptNoStt.Text & Chr(34) & "}"

            sfTransRes = PlateSYS.ServiceReferenceEdms_EdmsWebIFService_SfTrans(sfTransReq)
            Dim js As JObject
            js = JObject.Parse(sfTransRes.SfTransReturn)

            If js.SelectToken("Code") = "0" Then
                rtn = True
            Else
                'ERROR -> webService
                'MsgBox(js.SelectToken("Message"))
                Dim err As String = ""
                err = js.SelectToken("Message")
                Dim msg As String
                msg = "{"
                msg &= Chr(34) & "EquipNo" & Chr(34) & ":" & Chr(34) & lblEquipID.Text & Chr(34) & ","
                msg &= Chr(34) & "ErrorMessage" & Chr(34) & ":" & Chr(34) & err & Chr(34) & "}"
                tokenRes = PlateSYS.ServiceReferenceEdms_EdmsWebIFService_GetToken(tokenReq)
                PlateSYS.SfException(tokenReq.User, tokenRes.GetTokenReturn, msg)
            End If

        Catch ex As Exception
            setCheckInfo(ex.Message)
            Return rtn
        End Try
        Return rtn
    End Function
    Private Sub sendPLTError(getMsg As String)

        Dim PlateSYS As New ServiceReferenceEdms.EdmsWebIFServiceClient

        Dim tokenReq As New ServiceReferenceEdms.GetTokenRequest
        Dim tokenRes As New ServiceReferenceEdms.GetTokenResponse
        tokenReq.User = "edsf"
        tokenReq.Password = "edsf"

        Dim sfTransReq As New ServiceReferenceEdms.SfTransRequest
        Dim sfTransRes As New ServiceReferenceEdms.SfTransResponse
        Try

            Dim msg As String
            msg = "{"
            msg &= Chr(34) & "EquipNo" & Chr(34) & ":" & Chr(34) & lblEquipID.Text & Chr(34) & ","
            msg &= Chr(34) & "ErrorMessage" & Chr(34) & ":" & Chr(34) & getMsg & Chr(34) & "}"
            tokenRes = PlateSYS.ServiceReferenceEdms_EdmsWebIFService_GetToken(tokenReq)
            PlateSYS.SfException(tokenReq.User, tokenRes.GetTokenReturn, msg)

        Catch ex As Exception
            setCheckInfo(ex.Message)

        End Try

    End Sub
    Overrides Sub JoError()
        Dim rtn As Boolean = False
        Dim PlateSYS As New ServiceReferenceEdms.EdmsWebIFServiceClient


        Dim tokenReq As New ServiceReferenceEdms.GetTokenRequest
        Dim tokenRes As New ServiceReferenceEdms.GetTokenResponse
        tokenReq.User = "edfs"
        tokenReq.Password = "edfs"

        Dim sfTransReq As New ServiceReferenceEdms.SfTransRequest
        Dim sfTransRes As New ServiceReferenceEdms.SfTransResponse
        Try
            tokenRes = PlateSYS.ServiceReferenceEdms_EdmsWebIFService_GetToken(tokenReq)
            If outHeader Is Nothing Then
                PlateSYS.SfException("edfs", tokenRes.GetTokenReturn, outHeader.Message)
            End If
        Catch ex As Exception
            setCheckInfo(ex.Message)
        End Try

    End Sub

    Overrides Function isSameRackNo(rackNo As String) As Boolean
        If rackNo = txt0102.Text Or txt0103.Text = rackNo Then
            Return True
        Else
            Return False
        End If
        Return True
    End Function
    'Overrides Sub setProcessingLot()

    'End Sub

    Overrides Sub chkPLT()
        If chkMatChanged() Then
            PutLog(Me.ToString, "PQC", "PLT Doing PQC CHECK wiht keyNo.") '2020/8/8 ver.57

            chkPQC()
        End If
    End Sub

#Region "自動着完工　ほかの処理"
    ''' <summary>
    ''' コマンド受信
    ''' 受信コマンドの解析結果を各画面に渡す
    ''' </summary>
    ''' <param name="receiveData">受信コマンド</param>
    Protected Overrides Sub CommandReceive(receiveData As receiveCommandData)
        'MsgBox("Baseクラスの「CommandReceive」メソッドに入った！")
        HideCommandWaiting()
        If IsNothing(receiveData) Then
            Exit Sub
        End If

        '--------着工コマンド処理-------    
        If AUTO_MANUAL_BTN = TYPE_AUTO AndAlso receiveData.commandId = COMMAND_LN Then
            If chkErrorRackNo(receiveData, receiveData.commandId) = False Then
                sendPLTError("读取的着工料盒为【ERROR】，请重新处理。")
                Exit Sub
            End If
            PutLog(Me.ToString, "LN", "Begin") '2020/8/8 ver.58
            LN_COLSED = False
            'MsgBox("LN　コマンドを受け入れた！")
            LN_FLAG = True

            If NP_IU_RTN = False And setBufferLN() Then 'ADD 2020/8/17 miaojf Ver.70
                WaitLnCommand = receiveData
                Exit Sub
            End If
            'RACKからLOT情報を取得し、画面に設定する
            If IsNothing(IcTag.szLotNo) OrElse IcTag.Status = TagProcessStatus.Ready OrElse isSameRackNo(receiveData.LrackNoList(0)) = False Then
                PutLog(Me.ToString, "LN->LN", "DO") '2020/8/8 ver.58
                'Sleep(2000)
                '入力ラックNoからロットNoを取得
                If receiveData.LrackNoList(0).Substring(0, 1).ToUpper = "M" Then
                    PutLog(Me.ToString, "RECEIVEDATA LN ERROR", "ZB1") '2020/8/8 ver.57
                    Exit Sub
                End If

                setBeforeRackNo(receiveData.LrackNoList(0))

                txtLotNo.Text = getLotNoByRack(receiveData.LrackNoList(0))
                Me.Refresh()
                If txtLotNo.Text = "" Then
                    sendPLTError("ZA1-ZB1")
                    PutLog(Me.ToString, "RECEIVEDATA LN ERROR", getMsgStr("MSG10059", receiveData.LrackNoList(0))) '2020/8/8 ver.57
                    Exit Sub
                End If
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                Me.Refresh()
                setBeforeRackNo(receiveData.LrackNoList(0))
                'If checkBsiteMachineInf() = False Then Exit Sub
            End If
            If chkMatChanged() Then
                PutLog(Me.ToString, "PQC", "PLT Doing PQC CHECK in AUTO MODE.") '2020/8/8 ver.57

                chkPQC()
            End If
            PutLog(Me.ToString, "LN", "End") '2020/8/8 ver.58
            LN_COLSED = True
        End If
        If receiveData.commandId = COMMAND_LD Then

            If LN_COLSED = False Then
                PutLog(Me.ToString, "LD", "LN_COLSED = False") '2020/8/8 ver.58
                WaitLDCommand = receiveData
                Exit Sub
            End If
            PutLog(Me.ToString, "Command_LD_Received", Command_LD_Received)

            'MsgBox("LD　コマンドを受け入れた！")
            If Command_LD_Received = True Then

                sendPLTError("收到的为LD,设备应先发送LN命令,本次处理中止")
                PutLog(Me.ToString, "RECEIVEDATA LD ERROR", "DB:收到的为LD,设备应先发送LN命令,本次处理中止") '2020/8/8 ver.57

                Exit Sub
            End If
            'ADD MIAOJF 2020/07/18 begin
            If reconfirmNBIGS = True Then
                If receiveData.result = COMMAND_RESULT_OK Then
                    sendPLTError(getMsgStr("MSG00117", "照合成功。"))
                    PutLog(Me.ToString, "RECEIVEDATA LD OK2", getMsgStr("MSG00117", "照合成功。")) '2020/8/8 ver.57

                Else
                    ShowCommandResult(receiveData.result)
                    PutLog(Me.ToString, "RECEIVEDATA LD NG2", "照合失败。") '2020/8/8 ver.57

                End If
                reconfirmNBIGS = False
                Exit Sub
            End If
            'ADD MIAOJF 2020/07/18 END

            If receiveData.result = COMMAND_RESULT_OK Then
                Command_LD_Received = True
                WorkStart()
                Command_LD_Received = False
            Else
                ShowCommandResult(receiveData.result)
                PutLog(Me.ToString, "RECEIVEDATA LD NG", "照合失败。") '2020/8/8 ver.57

            End If
        End If

        '--------完工コマンド処理-------
        If AUTO_MANUAL_BTN = TYPE_AUTO AndAlso receiveData.commandId = COMMAND_LH Then
            If chkErrorRackNo(receiveData, receiveData.commandId) = False Then
                Exit Sub
            End If
            PutLog(Me.ToString, "LH", "Begin") '2020/8/8 ver.58
            If receiveData.LrackNoList(0).Substring(0, 1).ToUpper = "M" Then
                PutLog(Me.ToString, "RECEIVEDATA LH ERROR", "ZB1") '2020/8/8 ver.57
                Exit Sub
            End If
            'MsgBox("LH　コマンドを受け入れた！")
            If isSameLot(receiveData) = False Then
                '入力ラックNoからロットNoを取得
                Dim lot As String = getLotNoByRack(receiveData.LrackNoList(0))
                If lot = "" Then
                    Dim str As String = "根据着工料盒找不到关联组立KeyNo.(着工料盒：" & receiveData.LrackNoList(0) & ")"
                    PutLog(Me.ToString, "LH ERROR", str) '2020/8/8 ver.58
                    sendPLTError(str)
                    Exit Sub
                End If

                txtLotNo.Text = lot
                LC_SEND_FLG = False
                txtLotNo_KeyPress(txtLotNo, New KeyPressEventArgs(vbCr))
                LC_SEND_FLG = True
                setBeforeRackNo(receiveData.LrackNoList(0))
                If checkBsiteMachineInf() = False Then Exit Sub

            End If

            If IcTag.Status <> TagProcessStatus.Processing Then
                PutLog(Me.ToString, "LH", "处理LOT : " & IcTag.szLotNo & "不是着工中状态。") '2020/8/8 ver.58
                sendPLTError("处理LOT : " & IcTag.szLotNo & "不是着工中状态。处理中止。")
                IcTag = New TagData 'add 20200911 miaojf 
                Exit Sub
            End If

            LH_FLAG = True
            '不良内容をSF画面に表示する
            'setErrorInfo(receiveData)
            '完了MSラックNo.の設定
            If setAfterRackNo(receiveData) = False Then
                sendPLTError("指令中的【完了料盒号】读取错误。请检查设备。")
                PutLog(Me.ToString, "RECEIVEDATA LD NG", "指令中的【完了料盒号】读取错误。请检查设备。") '2020/8/8 ver.57
                Exit Sub
            End If
            'WB 画面清空后再发NP,IU.为NP所准备
            NPP.szLotNo = IcTag.szLotNo
            NPP.szDifLotNo = IcTag.szDifLotNo
            NPP.ProcessCD = lblProcessCD.Text
            NPP.EQUIP_ID = g_CURRENT_EQUIP_ID
            NPP.EQUIP_No = lblEquipID.Text
            NPP.OptNoEnd = txtOptNoEnd.Text
            NPP.kindNm = lblkindNm.Text
            NPP.Shape = lblShape.Text
            NPP.PbLayout = lblPbLayout.Text

            If EndCheck() Then
                'ADD 2020/9/12 miaojf Ver.80
                If IsNothing(outHeader) = False Then
                    outHeader.Status = STS_WARNING
                End If
                'bSiteへ計上処理
                btnTotalComp.PerformClick()
                '画面表示を初期化
                setinitializForm_FLG()

                If IsNothing(outHeader) = False AndAlso STS_SUCCESS.Equals(outHeader.Status) And initializForm_FLG = True Then 'UPD 2020/9/12 miaojf Ver.80
                    initializForm()
                End If


                PutLog(Me.ToString, "LH", "END") '2020/8/8 ver.58
            End If

        End If
        '--------材料補充処理-------
        'If receiveData.commandId = COMMAND_DL Then

        '    '====================================
        '    'ShowBsiteWaiting()

        '    ''設備の情報（治具、材料）を退避する
        '    'getMachinInf()

        '    ''材料ロットを補充
        '    'MaterialLotSetup(receiveData)
        '    ''型名を補充
        '    '====================================


        '    '処理モード１か判断：１ではない場合、処理中止 1の場合、処理続行
        '    If receiveData.mode <> "1" Then Exit Sub
        '    If chkMaterialType(receiveData.matType) = True Then
        '        callAtlasExec(receiveData.matType, receiveData.matName)

        '        'bSiteのエラーメッセージ
        '        'Dim bsiteMess As New clsDbBsiteMess
        '        'Dim errDt = bsiteMess.GetErrorList(m_szIP)

        '        ''検索結果がある場合、NG。でなければ、OK
        '        'Dim rtn As String = OK
        '        'If IsNothing(errDt) OrElse errDt.Rows.Count = 0 Then
        '        '    rtn = OK
        '        'Else
        '        '    rtn = NG
        '        'End If
        '        'setChangeForPQC(receiveData)
        '        'DMコマンドの送信
        '        sendDMCommand(COMMAND_DM, bsiteRtn, lblEquipID.Text, receiveData.matType, receiveData.matName, receiveData.matLotNo, receiveData.caseNo)

        '        If bsiteRtn Then setChangeForPQC(receiveData)
        '    End If

        'End If
    End Sub

#End Region
    Public Overrides Sub updateRackInfo()
        Dim rackNo As New ArrayList
        Dim dbLot As New clsDbLotDefect
        If txt0202.Text <> "" Then
            rackNo.Add(txt0202.Text)
        End If
        If txt0203.Text <> "" Then
            rackNo.Add(txt0203.Text)
        End If

        dbLot.DelInsRackInfo(IcTag.szLotNo, rackNo)
    End Sub

    Overrides Sub canceledAfter()
        Me.Refresh()
        MyBase.setProcessingLot()
    End Sub

    Overrides Function chkMatChanged() As Boolean
        Dim rtn1 As Boolean = False
        Dim rtn2 As Boolean = False
        Dim rtn3 As Boolean = False
        Dim rtn4 As Boolean = False
        Dim pqc As New clsPQCCheck

        Dim dt As DataTable = pqc.selectPQC_Check(g_CURRENT_EQUIP_ID)
        If lblProcessCD.Text = "S121" Then
            If IsDBNull(dt.Rows(0)("ZERO_FIRST_DT")) = True OrElse CDate(dt.Rows(0)("ZERO_FIRST_DT")).Date < objDBCondData.GetServerTime Then
                pqc.setZeroFirstDT(g_CURRENT_EQUIP_ID)
                setChangeForPQC("", "SF", "制品", "组成测量(每日)", "-")
            End If
        End If

        '如果已发送过PQC，则跳过Check
        If pqc.chkLotPQCSended(txtLotNo.Text) = True Then
            Return False
        End If

        '-----------------------车品PQC-------------------------
        If m_cLotInfo.isCar(txtLotNo.Text) = True Then
            'If pqc.isSameWaferLot(g_CURRENT_EQUIP_ID, IcTag.szDifLotNo) = True Then
            '    rtn1 = False
            'Else
            '    pqc.updateCarWaferLot(g_CURRENT_EQUIP_ID, IcTag.szDifLotNo)

            setChangeForPQC("", "SF", "车品PQC", "车品PQC（每lot）", "-")
                rtn1 = True


                'End If
            End If


        '------每装置9:00、21:00后首lot-------
        If IsDBNull(dt.Rows(0)("CLASS_FIRST_DT")) Then
            'pqc.setClassFirst(g_CURRENT_EQUIP_ID)
            setPLT_FLAG()
            dt = pqc.selectPQC_Check(g_CURRENT_EQUIP_ID)
            rtn2 = False
        Else
            If objDBCondData.GetServerTime > CDate(dt.Rows(0)("CLASS_FIRST_DT")) Then

                setChangeForPQC("", "SF", "制品", "班次切替", "-")
                    'pqc.setClassFirst(g_CURRENT_EQUIP_ID)
                    setPLT_FLAG()
                    dt = pqc.selectPQC_Check(g_CURRENT_EQUIP_ID)
                    rtn2 = True

            Else
                    rtn2 = False
            End If

        End If

        '------每装置每班每PKG首次lot------
        If lblProcessCD.Text = "S121" Then
            If dt.Rows(0)("S121_PKG").ToString.Contains(lblShape.Text.Substring(0, 8)) = False Then

                setChangeForPQC("", "SF", "PKG切替", "PKG切替(每班)", "-")
                    pqc.setS121PKG(g_CURRENT_EQUIP_ID, lblShape.Text.Substring(0, 8))
                    rtn3 = True

            End If
            ElseIf lblProcessCD.Text = "S122" Then
            If dt.Rows(0)("S122_PKG").ToString.Contains(lblShape.Text.Substring(0, 8)) = False Then

                setChangeForPQC("", "SF", "PKG切替", "PKG切替(每班)", "-")
                    pqc.setS122PKG(g_CURRENT_EQUIP_ID, lblShape.Text.Substring(0, 8))
                    rtn3 = True

            End If
            End If
        '-------每装置每次S121、S122切替lot-----
        If dt.Rows(0)("PROC_CD").ToString = "" Or dt.Rows(0)("PROC_CD").ToString <> lblProcessCD.Text Then

            setChangeForPQC("", "SF", "镀种切替", "镀种切替", "-")
                pqc.setProcCD(g_CURRENT_EQUIP_ID, lblProcessCD.Text)
                rtn4 = True

        End If
            Return (rtn1 Or rtn2 Or rtn3 Or rtn4)
    End Function

    Protected Overrides Sub chkPLT_ZERO()
        '------每装置S121工程 0点后首lot------
        Dim objPQCCheck As New clsPQCCheck

        '如果已发送过PQC，则跳过Check
        'If objPQCCheck.chkLotPQCSended(txtLotNo.Text) = True Then
        '    Exit Sub
        'End If

        Dim dt As DataTable = objPQCCheck.selectPQC_Check(g_CURRENT_EQUIP_ID)
        If lblProcessCD.Text = "S121" Then
            If IsDBNull(dt.Rows(0)("ZERO_FIRST_DT")) = True OrElse CDate(dt.Rows(0)("ZERO_FIRST_DT")).Date < objDBCondData.GetServerTime Then
                objPQCCheck.setZeroFirstDT(g_CURRENT_EQUIP_ID)
                setChangeForPQC("", "SF", "制品", "组成测量(每日)", "-")
            End If
        End If
    End Sub
    Protected Overrides Sub setPLT_FLAG()
        '------每装置9:00、21:00后首lot-------
        Dim objPQCCheck As New clsPQCCheck
        objPQCCheck.setClassFirst(g_CURRENT_EQUIP_ID)
        objPQCCheck.setS121PKG(g_CURRENT_EQUIP_ID, "")
        objPQCCheck.setS122PKG(g_CURRENT_EQUIP_ID, "")
    End Sub


    Protected Overrides Function getProcessingLot() As String

        Dim mOutParam As New InSiteWebService.OutViewMachine
        Dim InHeader As New InSiteWebService.InHeader
        Dim rtnlot As String = ""
        Dim clientStr As String = GetBsiteClientString()
        ShowBsiteWaiting()
        mOutParam = ViewMachineService_GetInf(lblEquipID.Text, clientStr) '装置検索
        HideCommandWaiting()
        If IsNothing(mOutParam.MachineInf.InProcLotInf) OrElse mOutParam.MachineInf.InProcLotInf.Count = 0 Then
            rtnlot = ""
        Else
            For i As Integer = 0 To mOutParam.MachineInf.InProcLotInf.Length - 1
                Dim dt1 As DataTable = m_cData.GetWbLotData(mOutParam.MachineInf.InProcLotInf(i).Lot)
                If dt1.Rows.Count > 0 Then
                    Dim param As InSiteWebService.InViewLot = New InSiteWebService.InViewLot()
                    param.Name = mOutParam.MachineInf.InProcLotInf(i).Lot
                    Dim viewLotServiceInfo As InSiteWebService.OutLotStd = mdl_ViewLotService.ViewLotServiceGet(param, clientStr)
                    If Not IsNothing(viewLotServiceInfo) AndAlso STS_SUCCESS.Equals(viewLotServiceInfo.Header.Status) Then
                        If viewLotServiceInfo.LotInf.OperationID.ToString.Substring(0, 2) = "S1" Then
                            rtnlot = mOutParam.MachineInf.InProcLotInf(i).Lot
                            Exit For
                        End If
                    End If
                End If
            Next

        End If

        Return rtnlot

    End Function
End Class
